<?php 
	
	function getUser() {
		$is_logged_in = $this->session->userdata('is_logged_in');
        if(isset($is_logged_in) && ($is_logged_in == true)){
            return $this->session->userdata('username');
        }
        else return false;
	}

	function createMenu() {
		// $this->load->model('model_categories');
		$CI =& get_instance();
        $CI->load->model('model_categories');

		$listCat = $CI->model_categories->getMenu();

		$strMenu = '';
		$strMenu .=  '<ul class="menu">';
		foreach ($listCat as $parent) {
			if ($parent->parent_cat == 'null') {
				$strMenu .= '<li>';
					$strMenu .= '<a href="'.base_url().'book/category/'.$parent->id_cat.'">' . $parent->name_cat . '</a>';
					$strMenu .= '<ul>';
					foreach ($listCat as $child) {
						if ($child->parent_cat == $parent->id_cat)
							$strMenu .= '<li><a href="'.base_url().'book/category/'
							.$child->id_cat.'">' . $child->name_cat . '</a></li>';
					}
					$strMenu .= '</ul>';
				$strMenu .= '</li>';
			}
		}
		$strMenu .= '</ul>';

		return $strMenu;
	}

?>